<%@page import="com.kaishengit.entity.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.kaishengit.util.Page"%>
<%@page import="com.kaishengit.entity.Sale"%>
<%@page import="com.kaishengit.util.Stringutil"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  
    
    <title>My JSP 'sousuo.jsp' starting page</title>
    <link rel="stylesheet"  type="text/css"  href="style/bootstrap.min.css"/>
	<style  type="text/css">
		.my{
			margin-top:60px;
		}
	</style>
  </head>
  
  <body>
  <div style="z-index: 5" class="topbar-wrapper">
    <div data-dropdown="dropdown" class="topbar">
      <div class="topbar-inner">
        <div class="container">
          <h3><a href="#">Project Name</a></h3>
          <ul class="nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#">Link</a></li>
            <li><a href="#">Link</a></li>
            <li><a href="#">Link</a></li>
            <li class="dropdown">
              <a class="dropdown-toggle" href="#">Dropdown</a>
              <ul class="dropdown-menu">
                <li><a href="#">Secondary link</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Another link</a></li>
              </ul>
            </li>
          </ul>
     
          <ul class="nav secondary-nav">
            <li class="dropdown">
              <a class="dropdown-toggle" href="#">Dropdown</a>
              <ul class="dropdown-menu">
                <li><a href="#">Secondary link</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Another link</a></li>
              </ul>
            </li>
            <li  style="fond-size:20px"><a>欢迎管理员：</a></li>
            <%User user = (User)session.getAttribute("admin"); %>
            <li ><a style="fond-size:20px"><%=user.getName() %></a></li>
          </ul>
        </div>
      </div><!-- /topbar-inner -->
    </div><!-- /topbar -->
  </div>
  <div class="my">
  <a  href="product.html?s=toexcel"><input  type="button" value="导出excel"  class="btn success"/></a>
  		<table   class="zebra-striped">
  			<thead><tr><th>时间</th><th>单位</th><th>导游</th><th>客源地</th><th>人数</th><th>销售额</th><th>客单价</th></thead>
  			<tbody>
  				<% Page<Sale>  pagelist =(Page<Sale>) request.getAttribute("page");
  					List<Sale>  salelist = pagelist.getResult();
  					List<Sale>  listall =(List<Sale>) session.getAttribute("list");  
  					
  					if(salelist==null){%>
  					<tr>没有符合条件的数据</tr>
  					<%}else {
  					int counts = pagelist.getCount();
  					int renshu = 0;
  					 float totalsale = 0;
  					 float danjia = 0;
  					
  					for(int j = 0;j<listall.size();j++){
  					totalsale+=listall.get(j).getSale();
  					renshu+=listall.get(j).getNum();
  					}
  					if(renshu==0){
  						danjia=0;
  					}else {
  						danjia = totalsale/renshu;
  					 Stringutil  su = new  Stringutil();
  					 danjia = su.getFloat(danjia);
  					}
  					
  					for(int i=0;i<salelist.size();i++){
  					Sale s = salelist.get(i);
  					%>
  					<tr>
  					<td><%=s.getTime() %></td>
  					<td><%=s.getTour().getTourname() %></td>
  					<td><%=s.getGuide().getName() %></td>
  					<td><%=s.getAddress() %></td>
  					<td><%=s.getNum() %></td>
  					<td>￥<%=s.getSale() %></td>
  					<td>￥<%=s.getPersale() %></td>
  					</tr>
  					<% }%>
  			</tbody>
  			<tfoot>
  				<tr>
  						<td>总记录条数是：<%=counts %></td>
  						<td>总销售额是：<%=totalsale %></td>
  						<td>总人数：<%=renshu %></td>
  						<td>平均客单价：<%=danjia %></td>
  					</tr>
  			</tfoot>
  		</table>
  		<div class="pagination">
  		<ul>
  				<%if(pagelist.getPageNum()==1){%>
  				<li class="prev disabled"><a>首页</a></li>	
  				<%}else {%>
  				<li class="prev"><a href="product.html?p=1&s=fenye">首页</a></li>
  				<%}
  				if(pagelist.getPageNum()==1){%>
  				<li><a>上一页</a></li>
  				<%}else {%>
  				<li><a href="product.html?s=fenye&p=<%=pagelist.getPageNum()-1%>">上一页</a></li>
  				<%} if(pagelist.getPageNum()==pagelist.getTotalPages()){%>
  				<li><a >下一页</a></li>
  				<%} else {%>
  				<li><a href="product.html?s=fenye&p=<%=pagelist.getPageNum()+1%>">下一页</a></li>
  				<%} if(pagelist.getPageNum()==pagelist.getTotalPages()){%>
  				<li class="next disabled"><a>尾页 </a></li>
  				<%}  else {%>
  				<li class="next"><a href="product.html?s=fenye&p=<%=pagelist.getTotalPages() %>">尾页 </a></li>
  				<%}%>
  				<li><a>总共<%=pagelist.getTotalPages() %>页</a></li>
  		</ul>
  		</div>
  		<%} %>
  		</div>
  </body>
</html>
